
package com.anwen.mongoa.entity.base;

import com.alibaba.ttl.TransmittableThreadLocal;

public final class RequestIdHolder {
    private static final ThreadLocal<String> THREAD_LOCAL_REQUEST_ID = new TransmittableThreadLocal();

    public static void setRequestId(String requestId) {
        THREAD_LOCAL_REQUEST_ID.set(requestId);
    }

    public static String getRequestId() {
        return (String)THREAD_LOCAL_REQUEST_ID.get();
    }

    public static void clear() {
        THREAD_LOCAL_REQUEST_ID.remove();
    }

    private RequestIdHolder() {
        throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
    }
}
